< previous page page_37 next page >

Page 37
The first statement sets the label's font to 18-point Arial. Arial happens to have an 18-point size, but it really does not matter because the second statement immediately changes the font's size to 21 point. Now the label uses 21-point Arial, which is what you wanted. To avoid problems, always set a font's name before you set its size.
The exception to this rule is when you use very small point sizes. Many fonts are hard to read at sizes smaller than 8 point. If you try to use a font in a size smaller than 8 point, and that size is not supported by that font, Windows may automatically switch typefaces for you and pick a font that is more legible. For example, if you try to use the Arial font at a size smaller than 8 point, Windows may switch to a font called Small Fonts. This font is legible (barely) down to around 5.25 points.
Other Font Properties
The Font object's Bold, Italic, StrikeThrough, and Underline properties are all Boolean properties. They determine whether text is bold, italicized, struck through, or underlined. You can mix these properties to make combined styles like bold, italic, and underlined.
The Weight property is another way to specify whether text is bold. If you set the Weight to the default value 400, the text is not bold. If you set Weight to 700, the text is bold. If you set Weight to any other value, Visual Basic changes the Weight to either 400 or 700, whichever is closer to the value you specified. You can make your code easier to read by using the Bold property instead of Weight.
Example program ShowFont, shown in Figure 1.20, displays samples of the fonts available on your screen. Check the Bold, Italic, StrikeThrough, and Underline boxes to determine the font's properties. Enter the font's size and click on one of the font names to see a sample of that font.
0037-01.jpg
Figure 1.20
Example program ShowFont displays samples of fonts.

 
< previous page page_37 next page >